<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
 String path = request.getContextPath();
 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
<html>
<head>
    <meta charset="UTF-8">
    <title>会员列表</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- Bootstrap 3.3.4 -->
    <link href="${ctx}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- FontAwesome 4.3.0 -->
    <link href="${ctx}/static/plugins/datatables/css/matrix-style.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/dist/css/AdminLTE.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/plugins/datatables/css/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/css/basic.css" rel="stylesheet" type="text/css">
    <style type="text/css">
		.right_btn{
			float: right;
		}
		.left_btn{
			float:left;
			padding:10px 0px 10px 20px
		}
		.form-group{
			display: inline-flex;
		}
		.s_table{
			width: 100%;
			padding: 20px 20px 20px 0px;
		}
		.s_table tr{
			height: 50px;
			margin: 10px;
		}
		.form-control{
			width: 80%;
		}
		.right_btn{
			float: right;
			margin-right: 5%;
		}
		.s_table label{font-weight: 400;}
		.s_table td{
			font-weight: normal;
			padding-right: 10px;
		}
    </style>
</head>
<body>
<div class="wrapper">
	<div class="widget-box">
		<div class="widget-title">
		   <h5>请输入查询条件</h5>
		</div>
		<div class="widget-content nopadding">
			<table class="s_table">
				<tr>
					<td colspan="6">
						<div class="left_btn">
				          <button type="button" onclick="exportExecl();"  class="btn btn-primary"><i class="fa fa-download space"></i>导出审核列表</button>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<label for="id">会员ID：</label>
					</td>
					<td>
						<input type="text" class="form-control" id="id" placeholder="会员ID">
					</td>
					<td>
						<select class="form-control" id="accountType">
							<option value="1">新业态推广师</option>
							<option value="2">本地电商推广师</option>
						</select>
					</td>
					<td>
						<input type="text" class="form-control" id="account" placeholder="">
					</td>
					<td>
						<label for="member_name">联系人：</label>
					</td>
					<td>
						<input type="text" class="form-control" id="member_name" placeholder="联系人">
					</td>
				</tr>
				<tr>
					<td>
						<label>申请时间：</label>
					</td>
					<td>
						<input type="text" class="form-control" readonly="readonly"  id="create_time_str" data-type="date_00" onClick="WdatePicker({el:'create_time_str',maxDate:'#F{$dp.$D(\'create_time_end\')}'})">
					</td>
					<td>
						<label>至</label>
					</td>
					<td>
						<input type="text" class="form-control" readonly="readonly"  id="create_time_end" data-type="date_00" onClick="WdatePicker({el:'create_time_end',minDate:'#F{$dp.$D(\'create_time_str\')}'})">
					</td>
					<td>
						<label for="member_phone">手机号：</label>
					</td>
					<td>
						<input type="text" class="form-control" id="member_phone" placeholder="手机号">
					</td>
				</tr>
				<tr>
					<td>
						<label for="id_card">身份证号：</label>
					</td>
					<td>
						<input type="text" class="form-control" id="id_card" placeholder="身份证号">
					</td>
					<td> <label>状态：</label></td>
					<td> 
						<select class="form-control"  id="status">
							 <option value="">请选择</option>
		                     <option value="1">待审核</option>
		                     <option value="2">审核通过</option>
		                     <option value="3">审核不通过</option>
                 		</select>
	                 </td>
					
				</tr>
				<tr>
					<td colspan="6">
						<div class="right_btn">
								<button type="button" id="btn_query" class="btn btn-primary" onClick="query()">查询</button>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
	
	 <div class="row">
		 <div class="col-xs-12">
		 	<div class="box">
		 		 <div class="box-header">
	                 <h3 class="box-title">会员列表</h3>
	             </div>
	             <!-- 列表 -->
	             <div class="box-body table-responsive">
	             	<table id="dataTables" class="table table-bordered table-hover">
	             	</table>
	             </div>
		 	</div>
		 </div>
	</div>
</div>

<div hidden>
	<form action="${ctx}/api/memberauth/memberAuthExport"  id="memberAuthExport" method="post">
		<input type="hidden" name="id" value="" id="e_memberID"/>
		<input type="hidden" name="accountType" value="" id="e_accountType"/>
		<input type="hidden" name="account" value="" id="e_account"/>
		<input type="hidden" name="createTimeStr" value="" id="e_createTimeStr"/>
		<input type="hidden" name="createTimeEnd" value="" id="e_createEndTime"/>
		<input type="hidden" name="memberName" value="" id="e_memberName"/>
		<input type="hidden" name="memberPhone" value="" id="e_memberPhone"/>
		<input type="hidden" name="idCard" value="" id="e_idCard"/>
		<input type="hidden" name="status" value="" id="e_status"/>
	</form>	
</div>

<!-- 图片放大模态框 -->
<div class="modal fade" id="imageModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">图片</h4>
            </div>
            <div class="modal-body">
            	<img id="viewImage" src="">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- jQuery 2.1.4 -->
<script src="${ctx}/static/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!--Bootstrap v3.3.4-->
<script src="${ctx}/static/bootstrap/js/bootstrap.min.js"></script>
<!--bootstrap-datepicker-->
<script src="${ctx}/static/plugins/My97DatePicker/datePicker/WdatePicker.js"></script>
<!-- datatable -->
<script src="${ctx}/static/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="${ctx}/static/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<script>
   var tb;
   $(function () {
		//列表初始化
		tb = $('#dataTables').dataTable({
				"bServerSide": true,
				"sPaginationType": "full_numbers",
				"bJQueryUI": true,
				"sDom": '<"">t<"F"ip>',
				"sAjaxSource": "${ctx}/api/memberauth/list", //ajax调用接口
				"aoColumnDefs": [{sDefaultContent: '',aTargets: [ '_all' ]}],
	       		"aoColumns": [
					  	{ "sTitle" : "会员id","mData": "id" ,"class":"sClass"},
		                { "sTitle" : "新业态账号","mData": "account","class":"sClass" ,"mRender":function(data, type, full){
		                	var text = full.account;
	                    	if(full.accountType=='2'){
	                    		text="";
	                    	}
	                    	return text;
		                	}
					  	},
		                { "sTitle" : "本地电商账号","mData": "account","class":"sClass","mRender":function(data, type, full){
		                	var text = full.account;
	                    	if(full.accountType=='1'){
	                    		text="";
	                    	}
	                    	return text;
	                	} },
		                { "sTitle" : "联系人","mData": "memberName","class":"sClass" },
		                { "sTitle" : "手机号","mData": "memberPhone","class":"sClass" },
		                { "sTitle" : "身份证号","mData": "idCard","class":"sClass" },
		                { "sTitle" : "推广师证件","mData": "image","class":"sClass","mRender":function(data,type,full) {
		                	if (full.image) {
			                	return '<img src="'+full.image + '" width="40px;" height="40px;" onclick="enlarge(\''+full.image +'\');"></img>';
		                	}
		                	return '';
		                } },
		                { "sTitle" : "申请时间","mData": "createTime","class":"sClass" },
		                { "sTitle" : "状态","mData": "status","class":"sClass" ,"mRender":function(data, type, full){
		                	var text;
	                    	if(full.memberAuthStatus=='1'){
	                    		text="待审核";
	                    	} else if(full.memberAuthStatus=='2'){
	                    		text="审核通过";
	                    	} else if(full.memberAuthStatus=='3'){
	                    		text="审核未通过";
	                    	}
	                    	return text;
	                	}},
		                {"sTitle" : "操作","mData" : "id", "mRender" : function ( data, type, full ) {
		                	var check;
		                	if(full.memberAuthStatus=='1'){
		                		check = '<li class="divider"></li>';
		                		check += '<li><a href="#" onclick="check(\''+full.id+'\',2);">通过</a> </li>';
		                		check += '<li class="divider"></li>';
		                		check += '<li><a href="#" onclick="check(\''+full.id+'\',3);">不通过</a> </li>';
		                	}else if(full.memberAuthStatus=='2'){
	                     		check = '<li class="divider"></li>';
	                     		check += '<li><a href="#" onclick="check(\''+full.id+'\',3);">不通过</a> </li>';
	                     	}else if(full.memberAuthStatus=='3'){
	                     		check = '<li class="divider"></li>';
	                     		check += '<li><a href="#" onclick="check(\''+full.id+'\',2);">通过</a> </li>';
	                     	}
		                	
		                	var text = '<div class="btn-group" style="text-align:left;"><button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">操作 <span class="caret"></span></button>';
								  text = text+'<ul class="dropdown-menu" role="menu">';
								  text += check;
								  text = text + '</ul></div>';
								  return text;
							  } 
		                }
	            ],
		        "oLanguage" : {
		           "sProcessing" : "数据加载中······",
		           "sLengthMenu" : "显示 _MENU_ 条记录",
		           "sZeroRecords" : "没有您要搜索的内容！",
		           "sEmptyTable" : "列表中无数据存在！",
		           "sInfo" : "当前显示 _START_ 到 _END_ 条数据，共 _TOTAL_ 条数据",
		           "sInfoEmpty" : "显示 0 到 0 条记录",
		           "sInfoFiltered" : "数据列表中共  _MAX_ 条记录",
		           "oPaginate" : {
		               "sFirst" : "首页",
		               "sPrevious" : "上一页",
		               "sNext" : "下一页",
		               "sLast" : "末页"
		           }
		        },
		        "fnServerData" : function ( sSource, aoData, fnCallback, oSettings ) {
					oSettings.jqXHR = $.ajax( {
						"dataType" 	: 'json',
						"type" 		: "POST",
						"async"     : 'false',
						"url" 		: sSource,
						"data" 		: {
							'pageNum': (aoData[3].value/aoData[4].value)+1,
							'pageSize' :  aoData[4].value,
							'id'       :  $('#id').val(),
							'accountType' : $('#account_type').val(),
							'account' : $('#account').val(),
							'createTimeStr' : $('#create_time_str').val(),
							'createTimeEnd' : $('#create_time_end').val(),
							'memberName' : $('#member_name').val(),
							'memberPhone' : $('#member_phone').val(),
							'idCard' : $('#id_card').val(),
							'status' : $('#status').val()
						}, 
						"success"	: fnCallback
					} );
				},
		  });
   });
   //条件查询重新加载数据
   function query() {
 	  tb.fnDraw();
   };
   
   //审核操作
   function check(memberID,status) {
	   var confirmReult;
	   if(status == 2) {
		   confirmReult = confirm("确认通过吗");
	   } else if(status == 3) {
		   confirmReult = confirm("确认不通过吗");
	   }
	   if(confirmReult==true){
	  		 $.ajax({
	  			async:false,
	       		url:"${ctx}/api/memberauth/check",
	       		data:{memberId:memberID,status:status},
	       		type:"POST",
	       		dataType:"json",
	       		success:function(data){
	       			if(data.code=="200"){
	       				tb.fnDraw();
	       			}else{
	       				alert(data.message);
	       			}
	       		}
	  		 });
	  		 return;
	  	 }else{
	  		 return false;
	  	 }
   }

   /**
   * 推广师导出
   */
   function exportExecl() {
	   $('#e_id').val($('#id').val());
	   $('#e_accountType').val($('#account_type').val());
	   $('#e_account').val($('#account').val());
	   $('#e_createTimeStr').val($('#create_time_str').val());
	   $('#e_createTimeEnd').val($('#create_time_end').val());
	   $('#e_memberName').val($('#member_name').val());
	   $('#e_memberPhone').val($('#member_phone').val());
	   $('#e_idCard').val($('#id_card').val());
	   $('#e_status').val($('#status').val());
	   $('#memberAuthExport').submit();
   }
   
   //图片放大
   function enlarge(url) {
	   $('#viewImage').attr("src",url);
	   $("#imageModel").modal('show');
   }
</script>
</body>
</html>